
// 基于您的IPFS配置的铸造脚本
const { ethers } = require('ethers');

const CONTRACT_ADDRESS = "YOUR_CONTRACT_ADDRESS"; // 部署后替换
const CONTRACT_ABI = [/* 您的合约ABI */];

async function mintAllNFTs() {
    const provider = new ethers.providers.JsonRpcProvider(process.env.SEPOLIA_RPC_URL);
    const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
    const contract = new ethers.Contract(CONTRACT_ADDRESS, CONTRACT_ABI, wallet);
    
    const nftFiles = [
        "myNFT1.jpeg",
        "myNFT2.jpeg", 
        "myNFT3.jpeg",
        "myNFT4.jpeg",
        "myNFT5.jpeg"
    ];
    
    for (let i = 0; i < nftFiles.length; i++) {
        const fileName = nftFiles[i];
        console.log(`铸造NFT ${i + 1}: ${fileName}`);
        
        try {
            const tx = await contract.mintNFT(wallet.address, fileName);
            const receipt = await tx.wait();
            
            const mintEvent = receipt.events?.find(e => e.event === 'NFTMinted');
            const tokenId = mintEvent?.args?.tokenId;
            
            console.log(`✅ 铸造成功，Token ID: ${tokenId}`);
            
            // 验证URI
            const tokenURI = await contract.tokenURI(tokenId);
            console.log(`   URI: ${tokenURI}`);
            
        } catch (error) {
            console.log(`❌ 铸造失败: ${error.message}`);
        }
    }
}

mintAllNFTs().catch(console.error);
